#include "QiliSubtitleAvatar.h"

#include "QiliImageLoader.h"
#include <QObject>
#include <QPixmap>

QiliSubtitleAvatar::QiliSubtitleAvatar(const QString &url, QGraphicsItem *parent)
    : QGraphicsPixmapItem(parent), mImageLoader(new QiliImageLoader(url))
{
    QObject::connect(mImageLoader, &QiliImageLoader::ready, [this](auto pixmap) {
        QPixmap modified = pixmap.scaled(WIDTH, HEIGHT, Qt::KeepAspectRatio);
        this->setPixmap(modified);
    });
}
